import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '区划代码',
    align:"left",
     width: 180,
    dataIndex: 'id'
   },
   {
    title: '上级代码',
    align:"left",
     width: 180,
    dataIndex: 'pid'
   },
   {
    title: '等级',
    align:"center",
     width: 80,
    dataIndex: 'type',
     customRender: ({ text }) => {
       return render.renderDict(text, 'xzqh_type');
     },
   },
  {
    title: '全名',
    align:"left",
    dataIndex: 'namepath'
  },

   {
    title: '名称',
    align:"center",
     width: 200,
    dataIndex: 'name'
   },


];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
  },

  {
    label: '全名',
    field: 'namepath',
    component: 'JInput',
    colProps: { span: 6 },
  },

  {
    label: '区划代码',
    field: 'id',
    component: 'JInput',
    colProps: { span: 6 },
  },

  {
    label: '等级',
    field: 'type',
    component: 'JSelectMultiple',
    componentProps: {
      dictCode: 'xzqh_type',
      placeholder: '请选择等级',
    },
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '上级代码',
    field: 'pid',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输上级代码!'},
      ];
    },
  },
  {
    label: '区划代码',
    field: 'id',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入区划代码!'},
          ];
     },
  },
  {
    label: '等级',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'xzqh_type',
      placeholder: '请选择等级',
      dynamicRules: ({model,schema}) => {
        return [
          { required: true, message: '请选择等级!'},
        ];
      },
    },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入名称!'},
      ];
    },
  },

];

// 高级查询数据
export const superQuerySchema = {
  id: {title: '区划代码',order: 0,view: 'number', type: 'number',},
  pid: {title: '上级代码',order: 1,view: 'text', type: 'string',},
  type: {title: '等级',order: 2,view: 'text', type: 'string',},
  name: {title: '名称',order: 3,view: 'text', type: 'string',},
  namepath: {title: '全名',order: 11,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
